package cn.example.backstage.examination.controller;

import cn.example.backstage.base.response.JsonResult;
import cn.example.backstage.examination.pojo.dto.ExaminationAddDTO;
import cn.example.backstage.examination.pojo.dto.ExaminationQuery;
import cn.example.backstage.examination.pojo.vo.ExaminationVO;
import cn.example.backstage.examination.service.ExaminationService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/v1/examination")
public class ExaminationController {
    @Autowired
    ExaminationService examinationService;
    @GetMapping("select")
    public JsonResult selectExamination(ExaminationQuery examinationQuery){
        List<ExaminationVO> list = examinationService.selectAll(examinationQuery);
        return JsonResult.ok(list);
    }
    @PostMapping("add")
    public JsonResult addExamination(@RequestBody ExaminationAddDTO examinationAddDTO){
        examinationService.addExamination(examinationAddDTO);
        return JsonResult.ok();
    }
    @DeleteMapping("delete/{id}")
    public JsonResult deleteExamination(@PathVariable Long id){
        examinationService.deleteById(id);
        return JsonResult.ok();
    }
}